package com.lyh.api;

import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author SHOUSHEN.LUAN
 * @since 2023-11-16
 */
public class MockData {

    public static List<Date> getDateList() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        List<Date> dates = new ArrayList<>();
        try {
            dates.add(new java.sql.Date(dateFormat.parse("2023-01-01").getTime()));
            dates.add(new java.sql.Date(dateFormat.parse("2023-04-01").getTime()));
            dates.add(new java.sql.Date(dateFormat.parse("2023-07-01").getTime()));
            dates.add(new java.sql.Date(dateFormat.parse("2023-10-01").getTime()));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        return dates;
    }

    public static Date randomDate() {
        List<Date> dates = getDateList();
        int index = ThreadLocalRandom.current().nextInt(dates.size());
        return dates.get(index);
    }
}
